package cn.e3.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import cn.e3.pagehelper.PageHelperResult;
import cn.e3.pojo.TbItem;
import cn.e3.service.ItemService;
import cn.e3.utils.E3Result;

@Controller
public class ItemController {
	@Autowired
	private ItemService itemService;
	@RequestMapping("/item/{id}")
	@ResponseBody
	public TbItem selectItemById(@PathVariable Long id){
		TbItem item = itemService.selectItemById(id);
		return item;
	}
	
	@RequestMapping("/item/list")
	public @ResponseBody PageHelperResult getitemPageList(Integer rows,Integer page){
		PageHelperResult result = itemService.getItemsList(page, rows);
		return result;
	}
	@RequestMapping(value="/item/save",method=RequestMethod.POST)
	@ResponseBody
	public E3Result insertItem(TbItem item,String desc){
		return itemService.insertItem(item, desc);
	}
}
